#include "S_BB.h"

uint16_t BBscale[16] = {262, 294, 330, 349, 392, 440, 494,
                    523, 587, 659, 698, 784, 880, 988,
                    1046, 1175};//网上查的频率对音阶表(不懂音乐

void BBinit(void)
{
    HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_4);//使能pwm输出
}

void BBfrec(uint16_t frec)
{
    htim3.Instance->ARR = (uint32_t)(1000000.0f / (float)frec - 1);
    htim3.Instance->CCR4 = htim3.Instance->ARR / 2;
}

void BBstop(void)//闭嘴
{
    htim3.Instance->CCR4 = 0;
}